﻿using System;
using System.Windows.Data;
using System.Globalization;

namespace T163.Open.Api.WP7.Sample.Converters
{
    public class DateTimeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return null;

            string format = "ddd MMM dd HH:mm:ss zzzz yyyy";

            return DateTime.ParseExact(value.ToString(), format, CultureInfo.InvariantCulture).ToString("yyyy/M/d h:m");
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
